package main

import (
	"fmt"
	"log"
	"os/exec"
)

func main() {
	var (
		cmd *exec.Cmd
		err error
		output []byte
	)

	//生成cmd
	cmd = exec.Command("/bin/bash","-c","sleep 2;ls -l")
	//执行了命令,捕获子进程的输出(pipe)
	if output,err = cmd.CombinedOutput();err != nil{
		log.Fatalf("err is %v:",err)
	}
	//打印子进程的输出
	fmt.Println(string(output))
	
}
